package com.qf.pojo;

import lombok.Data;

@Data
public class Result {

    public static final Integer SUCCESS = 1000;
    public static final Integer NO_LOGIN = 2000;
    public static final Integer FAILED = 3000;

    private String msg;
    private Object data;
    private Integer code;


    /**
     * 成功返回的结果
     * @param data
     * @return
     */
    public static Result success(Object data){
        Result result = new Result();
        result.setData(data);
        result.setCode(SUCCESS);
        return result;
    }

    /**
     * 未登录返回的结果
     * @param msg
     * @return
     */
    public static Result notLogin(String msg){
        Result result = new Result();
        result.setMsg(msg);
        result.setCode(NO_LOGIN);
        return result;
    }

    /**
     * 失败返回的结果
     * @param msg
     * @return
     */
    public static Result failed(String msg){
        Result result = new Result();
        result.setMsg(msg);
        result.setCode(FAILED);
        return result;
    }
}
